cmake_minimum_required(VERSION 3.10)
project(test_cv)

# 设置OpenCV路径
set(OpenCV_DIR "${CMAKE_SOURCE_DIR}/../3rdparty/opencv-345/_install_x86_64/share/OpenCV")
message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")

# 查找OpenCV库
# find_package(OpenCV REQUIRED)  # required，没找到强制停止
find_package(OpenCV)
if(OpenCV_FOUND)
    message(STATUS "成功找到OpenCV库，版本: ${OpenCV_VERSION}")
    message(STATUS "OpenCV头文件路径: ${OpenCV_INCLUDE_DIRS}")
else()
    message(FATAL_ERROR "未找到OpenCV库，请检查OpenCV是否正确安装或CMAKE_PREFIX_PATH是否设置正确")
endif()

# 包含OpenCV头文件
# include_directories(${OpenCV_INCLUDE_DIRS})

# 添加可执行文件
add_executable(test_cv main_cv.cpp)

# 链接OpenCV库
target_link_libraries(test_cv ${OpenCV_LIBS})